/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package e.z.blog.back.setup;

import e.z.blog.back.bean.base.Lan;
import e.z.blog.back.bean.system.Manager;
import org.nutz.dao.Dao;
import org.nutz.ioc.Ioc;
import org.nutz.mvc.NutConfig;
import org.nutz.mvc.Setup;
import z.h.w.jar.data.time.Time;

/**
 *
 * @author EnzoZhong
 */
public class ManagerSetup implements Setup {

        @Override
        public void init ( NutConfig config ) {
                Ioc ioc = config.getIoc();
                Dao dao = ioc.get( Dao.class , "dao" );
                /*
                 * 表创建
                 */
                dao.create( Manager.class , false );
                /*
                 * 插入默认值
                 */
                Manager defManager = ioc.get( Manager.class , "defManager" );
                if ( dao.fetch( Manager.class , defManager.getAccount() ) == null ) {
                        defManager.setBuildDate( Time.born() );
                        dao.insert( defManager );
                }
        }

        @Override
        public void destroy ( NutConfig config ) {
                throw new UnsupportedOperationException( "Not supported yet." );
        }
}
